//package com.example.bsxk.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.security.web.authentication.AuthenticationFailureHandler;
//import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
//
//@EnableWebSecurity
//public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
//    @Autowired
//    AuthenticationEntryPoint authenticationEntryPoint;
//    @Autowired
//    AuthenticationSuccessHandler successHandler;
//    @Autowired
//    AuthenticationFailureHandler failureHandler;
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        //super.configure(http);
//        http    //登陆配置
//                .formLogin()
//                .loginProcessingUrl("/login")//指定登录请求路径
//                .permitAll()//允许访问登陆请求
//                .successHandler(successHandler)//登陆成功的处理
//                .failureHandler(failureHandler)//登陆失败的处理
//                .and()
//                //认证配置，哪些路径需要认证
//                .authorizeRequests()
//                .antMatchers("/user/register").permitAll()//要放行的请求路径
//                .anyRequest()
//                .authenticated()
//                .and()
//                //未登录时调用认证出错的处理器
//                .exceptionHandling()   //认证出错时处理
//                .authenticationEntryPoint(authenticationEntryPoint)  //指定一个认证出错的处理器
//                .and()
//                .csrf().disable();//关闭csrf()
//    }
//    //创建密码加密器
//    //进行密码校验时调用密码加密器
//    @Bean
//    public PasswordEncoder createPasswordEncoder(){
//        return new BCryptPasswordEncoder();
//    }
//}
